import WorldMod from "../model/WorldMod";
import { ClientEvent } from "../event/ClinetEvent";
import { ISize } from "../../common/game/util/V2Util";
import BaseView from "../core/mvc/BaseView";

const { ccclass, property } = cc._decorator;
const et = ClientEvent.Type

@ccclass
export default class WorldView extends BaseView {

    @property(cc.Node)
    bgNode: cc.Node = null

    private _mod: WorldMod

    onLoad() {
        this._mod = WorldMod.ins

        this.ed.on(et.WORLD_SIZE_UPDATE, this, e => {
            this.updateBg(e.size)
        })
        this.updateBg(this._mod.worldSize)

    }

    /** 设置背景大小 */
    updateBg(size: ISize) {
        let { w, h } = size
        this.bgNode.width = w
        this.bgNode.height = h
    }

}
